package com.base.myproject.client.HR.Self;

import java.util.Date;

import com.base.myproject.client.busi.BaseStore;
import com.base.myproject.client.busi.BO.BusiObject;
import com.base.myproject.client.jdbc.StoreInfo;
import com.base.myproject.client.system.Env;
import com.base.myproject.client.tools.Tools;
import com.base.myproject.client.ui.BaseJDBCPanel;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author cxghiu410@gmail.com
 * 用于实现用户自助的界面功能
 */
public class SelfBcodeMain extends BaseJDBCPanel{
	
	BaseStore<BusiObject> store = null;
	String bcode = null;
	
	public SelfBcodeMain(){
		//bcode = "9999";
		getMainStore();
		init();
	}
	
	public void init(){
		this.add(initWeigetx());
		registerMainStore(store);
		registerStore(store);
	}
	
	public BaseStore<BusiObject> getMainStore(){
		if (store == null) {
			createMainStore();
		}
		return store;
	}
	
	public BaseStore<BusiObject> createMainStore(){
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("icode");
		type.getField("icode").setType(Long.class);
		type.addField("bcode");
		type.getField("bcode").setType(String.class);
		type.addField("up_department");
		type.getField("up_department").setType(String.class);
		type.addField("bname");
		type.getField("bname").setType(String.class);
		type.addField("departments");
		type.getField("departments").setType(String.class);
		type.addField("password");
		type.getField("password").setType(String.class);
		type.addField("email");
		type.getField("email").setType(String.class);
		type.addField("sex");
		type.getField("sex").setType(String.class);
		type.addField("edu");
		type.getField("edu").setType(String.class);
		type.addField("bird");
		type.getField("bird").setType(Date.class);
		type.addField("incom");
		type.getField("incom").setType(Date.class);
		type.addField("mobil");
		type.getField("mobil").setType(String.class);
		type.addField("idno");
		type.getField("idno").setType(String.class);
		type.addField("liveaddr");
		type.getField("liveaddr").setType(String.class);
		type.addField("systemid");
		type.getField("systemid").setType(String.class);
		type.addField("status");
		type.getField("status").setType(Integer.class);
		type.addField("bcode_bak");
		type.getField("bcode_bak").setType(String.class);
		type.addField("bname_bak");
		type.getField("bname_bak").setType(String.class);
		type.addField("bcodeshortcode");
		type.getField("bcodeshortcode").setType(String.class);
		type.addField("groupicode");
		type.getField("groupicode").setType(String.class);
		type.addField("canaddfinance");
		type.getField("canaddfinance").setType(Boolean.class);
		type.addField("candownload");
		type.getField("candownload").setType(Boolean.class);
		type.addField("caneditccode");
		type.getField("caneditccode").setType(Boolean.class);
		type.addField("canchangepo");
		type.getField("canchangepo").setType(Boolean.class);
		type.addField("isvirtual");
		type.getField("isvirtual").setType(Boolean.class);
		type.addField("hr_firstname_zh");
		type.getField("hr_firstname_zh").setType(String.class);
		type.addField("hr_lastname_zh");
		type.getField("hr_lastname_zh").setType(String.class);
		type.addField("hr_firstname_en");
		type.getField("hr_firstname_en").setType(String.class);
		type.addField("hr_lastname_en");
		type.getField("hr_lastname_en").setType(String.class);
		type.addField("hr_nametitle");
		type.getField("hr_nametitle").setType(String.class);
		type.addField("hr_name_Alias");
		type.getField("hr_name_Alias").setType(String.class);
		type.addField("hr_idcard_limitdate");
		type.getField("hr_idcard_limitdate").setType(Date.class);
		type.addField("hr_idcard_addr");
		type.getField("hr_idcard_addr").setType(String.class);
		type.addField("hr_idcard_abroad_addr");
		type.getField("hr_idcard_abroad_addr").setType(String.class);
		type.addField("hr_idcard_abroad_no");
		type.getField("hr_idcard_abroad_no").setType(String.class);
		type.addField("hr_nationality");
		type.getField("hr_nationality").setType(String.class);
		type.addField("hr_Marital_status");
		type.getField("hr_Marital_status").setType(String.class);
		type.addField("hr_marital_date");
		type.getField("hr_marital_date").setType(Date.class);
		type.addField("hr_Census_Province");
		type.getField("hr_Census_Province").setType(String.class);
		type.addField("hr_Census_city");
		type.getField("hr_Census_city").setType(String.class);
		type.addField("hr_City_Township");
		type.getField("hr_City_Township").setType(String.class);
		type.addField("hr_Census_area");
		type.getField("hr_Census_area").setType(String.class);
		type.addField("hr_social_no");
		type.getField("hr_social_no").setType(String.class);
		type.addField("hr_status");
		type.getField("hr_status").setType(String.class);
		type.addField("hr_entry_date");
		type.getField("hr_entry_date").setType(Date.class);
		type.addField("hr_bankno");
		type.getField("hr_bankno").setType(String.class);
		type.addField("hr_bankcard");
		type.getField("hr_bankcard").setType(String.class);
		type.addField("hr_imagepath");
		type.getField("hr_imagepath").setType(String.class);
		type.addField("shortcode");
		type.getField("shortcode").setType(String.class);
		type.addField("Identifier");
		type.getField("Identifier").setType(String.class);
		type.addField("salaryploy");
		type.getField("salaryploy").setType(String.class);
		type.addField("basesalary");
		type.getField("basesalary").setType(Double.class);
		type.addField("tax_tactics");
		type.getField("tax_tactics").setType(String.class);
		type.addField("isMul");
		type.getField("isMul").setType(Integer.class);
		
		StoreInfo info = new StoreInfo();
		info.setTablename("bcode");
		info.setKeyname(new String[]{"icode"});

		info.setSql("select * from bcode " +
				"where bcode='"+Env.getEnvbcode()+"'");
		store = new BaseStore<BusiObject>(type, info);
		return store;
	}
	
	private Widget initWeigetx()
	{
		TabPanel tabpanel = new TabPanel();
		tabpanel.setHeight(439);
		
		HorizontalPanel h = new HorizontalPanel();
		h.setSpacing(2);
		TabItem ti = new TabItem();
		SelfBcode_HR bcode_hr = new SelfBcode_HR(store);
		//注册store
		//registerStore(bcode_hr.getStore());
	  
		ti.add(bcode_hr);
		ti.setText("雇员");
		ti.setStyleName("tabitem_bg_color");
		ti.setScrollMode(Scroll.AUTO);
		ti.setAutoHeight(true);
		
		TabItem ti2 = new TabItem();
		ti2.setText("雇用工作");
		SelfBcode_Employment  bcode_employment = new SelfBcode_Employment(store);
		registerStore(bcode_employment.getStore());
		ti2.setStyleName("tabitem_bg_color");
		ti2.add(bcode_employment);
		ti2.setScrollMode(Scroll.AUTO);
		
		TabItem ti_add1 = new TabItem();
		ti_add1.setText("薪金");
		SelfBcode_salary  bcode_salary = new SelfBcode_salary(store);
		registerStore(bcode_salary.get_bcode_Allowance_Store());
		ti_add1.setStyleName("tabitem_bg_color");
		ti_add1.add(bcode_salary);
		ti_add1.setScrollMode(Scroll.AUTO);
		
		TabItem ti_add = new TabItem();
		ti_add.setText("发薪记录");
		ti_add.setStyleName("tabitem_bg_color");
		SelfBcode_SalaryRecord  selfBcode_salaryrecord = new SelfBcode_SalaryRecord(store);
		ti_add.add(selfBcode_salaryrecord);
		ti_add.setScrollMode(Scroll.AUTO);
		
		TabItem ti3 = new TabItem();
		ti3.setText("工作经历");
		ti3.setStyleName("tabitem_bg_color");
		SelfBcode_job_his bjh = new SelfBcode_job_his(store);
		ti3.add(bjh);
		ti3.setScrollMode(Scroll.AUTO);
		
		TabItem ti_add3 = new TabItem();
		ti_add3.setText("合同");
		ti_add3.setStyleName("tabitem_bg_color");
		SelfBcode_Contract  bcode_Contract = new SelfBcode_Contract(store);
		ti_add3.add(bcode_Contract);
		ti_add3.setScrollMode(Scroll.AUTO);
		
		/*TabItem ti_add2 = new TabItem();
		ti_add2.setText("培训");
		ti_add2.setStyleName("tabitem_bg_color");
		SelfBcode_Train  Bcode_Train = new SelfBcode_Train(store);
		//registerStore(bcode_salary.getBcode_EmploymentStore());
		//registerStore(bcode_salary.get_bcode_Allowance_Store());
		ti_add2.add(Bcode_Train);
		ti_add2.setScrollMode(Scroll.AUTO);*/
		
		TabItem ti4 = new TabItem();
		ti4.setText("资历");
		ti4.setStyleName("tabitem_bg_color");
		SelfBcode_Cer bcode_cer =new SelfBcode_Cer(store);
		
		registerStore(bcode_cer.get_bcode_cer_Store());
		registerStore(bcode_cer.get_bcode_quality_Store());
		registerStore(bcode_cer.get_bcode_skill_Store());
		registerStore(bcode_cer.getbcode_educationStore());
		ti4.add(bcode_cer);
		ti4.setScrollMode(Scroll.AUTO);
		
		
		TabItem ti5 = new TabItem();
		ti5.setText("家庭信息");
		ti5.setStyleName("tabitem_bg_color");
		SelfBcode_Family bcode_family = new SelfBcode_Family(store);
		registerStore(bcode_family.get_bcode_famify_Store());
		registerStore(bcode_family.get_bcode_Spouse_Store());
		ti5.add(bcode_family);
		ti5.setScrollMode(Scroll.AUTO);
		
		TabItem ti6 = new TabItem();
		ti6.setText("其他资料");
		ti6.setStyleName("tabitem_bg_color");
		SelfBcode_Extdata bcode_extdata = new SelfBcode_Extdata(store);
		ti6.add(bcode_extdata);
		registerStore(bcode_extdata.getStore());
		ti6.setScrollMode(Scroll.AUTO);
		
		
		tabpanel.add(ti);
		tabpanel.add(ti2);
		tabpanel.add(ti3);
		tabpanel.add(ti_add);
		tabpanel.add(ti_add1);
		tabpanel.add(ti_add3);
		tabpanel.add(ti4);
		//tabpanel.add(ti_add2);
		tabpanel.add(ti5);
		tabpanel.add(ti6);
		h.add(tabpanel);
		Tools.setResize(tabpanel,1.00,1.00);
		return h;
	}
}
